import org.codehaus.groovy.control.CompilerConfiguration

abstract class MyBaseClass extends Script {
    String name
     void greet() { println "Hello, $name!" }
}


def config = new CompilerConfiguration()
config.scriptBaseClass = 'MyBaseClass'
def shell = new GroovyShell(this.class.classLoader, config)
shell.evaluate """
    setName 'Judith'                                                    
    greet()
"""